<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
</head>
</head>
<body>
    <div id="app">
    {{watchedValue}}
    <button @click="handleClick"> 监听按钮</button>

    </div>
    <script>
    var app = new Vue({
    el:"#app",
    data:{
        watchedValue:"张三"
    },
    watch:{
        watchedValue(nval,oval) {
           console.log('新值',nval)
           console.log('旧值',oval)
        }   
    },
    methods:{
        handleClick(){
            this.watchedValue = "李四"
        }
    }

    })
    </script>
</body>
</html>